<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/ace.min.css">
    <link rel="stylesheet" href="css/ace-skins.min.css">
    <link rel="stylesheet" href="css/ace-responsive.min.css">
    <link rel="stylesheet" href="webuploader/webuploader.css">


  <style>
    body,html{
      width: 100%;
      height: 100%;
      background: #fff;
    }

    .modal{
      width: 800px;
      margin-left: -400px;
    }
    .form-control {
    display: block;
    width: 50%;
    height: 35px;
    line-height: 35px;
    margin-bottom: 20px;
    padding: 6px 12px;
    font-size: 14px;
    color: #555;
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
 .thumbnail {
    float: left;
    position: relative;
    margin: 0 20px 20px 0;
    width: 110px;
    height: 110px;
    padding: 4px;
  }
  .file-item .info {
    position: absolute;
    left: 4px;
    bottom: 4px;
    right: 4px;
    height: 20px;
    line-height: 20px;
    text-indent: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    z-index: 10;
}
#filePicker {
    display: inline-block;

    vertical-align: middle;
    margin: 0 12px 0 0;
}
.imgList{
  width: 30px;
  height: 30px;
}
  .red{
      width: 73%;
      margin: auto;
  }
  </style>
    <body>


    <div id="main-content" class="clearfix">
  <div id="page-content" class="clearfix">

    <div class="page-header position-relative" data-toggle="modal" data-target="#myModal">
      <h1 style="color: #2679b5;">品牌商 <small><i class="icon-double-angle-right"></i> 商品分类&主图</small></h1>
    </div>
      <form class="form-search">
          商品标题：
          <input type="text" class="input-medium search-query">
          <button onclick="return false;" class="btn btn-purple btn-small">Search <i class="icon-search icon-on-right"></i></button>
      </form>

      <table id="table_bug_report" class="table table-striped table-bordered table-hover">
      <thead>
        <tr>
          <th class="center">
            <label><input type="checkbox" class="ace-checkbox-2"><span class="lbl"></span></label>
          </th>
          <th>商品标题</th>
          <th>分类</th>
          <th class="hidden-480">主图</th>
          <th class="hidden-480">状态</th>
          <th>操作</th>
        </tr>
      </thead>

      <tbody>

        <tr>
          <td class="center">
            <label><input type="checkbox" class="input"><span class="lbl"></span></label>
          </td>
          <td>MP3</td>
          <td>电子产品</td>
          <td class="hidden-480"><img src="image/goods.png" alt="" class="imgList"></td>
          <td class="hidden-480"><span class="label label-sm label-warning">待入仓</span></td>
          <td>
            <div class="inline position-relative" >
              <button class="btn btn-mini btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-edit"></i></button>
              <button class="btn btn-mini btn-danger"><i class="icon-trash"></i></button>
                <button class="btn btn-mini btn-success">
                    入仓
                </button>
            </div>
          </td>
        </tr>


        <tr>
          <td class="center">
            <label><input type="checkbox" class="input"><span class="lbl"></span></label>
          </td>
          <td>电饭锅</td>
          <td>电器</td>
          <td><img src="image/goods.png" alt="" class="imgList"></td>
          <td><span class="label label-success">入仓中</span></td>
          <td>
            <div class="inline position-relative" >
              <button class="btn btn-mini btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-edit"></i></button>
              <button class="btn btn-mini btn-danger"><i class="icon-trash"></i></button>

            </div>
          </td>
        </tr>


        <tr>
          <td class="center">
            <label><input type="checkbox" class="input"><span class="lbl"></span></label>
          </td>
          <td>电冰箱</td>
          <td>电器</td>
          <td><img src="image/goods.png" alt="" class="imgList"></td>
          <td><span class="label label-inverse arrowed-in">待上架</span></td>
          <td>
            <div class="inline position-relative" >
               <button class="btn btn-mini btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-edit"></i></button>
              <button class="btn btn-mini btn-danger"><i class="icon-trash"></i></button>
                <button class="btn btn-mini btn-success">
                    上架
                </button>
            </div>
          </td>
        </tr>


        <tr>
          <td class="center">
            <label><input type="checkbox" class="input"><span class="lbl"></span></label>
          </td>
          <td>耳机</td>
          <td>电子产品</td>
          <td><img src="image/goods.png" alt="" class="imgList"></td>
          <td><span class="label label-sm label-info arrowed arrowed-righ">上架中</span></td>
          <td>
            <div class="inline position-relative" >
              <button class="btn btn-mini btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-edit"></i></button>
              <button class="btn btn-mini btn-danger"><i class="icon-trash"></i></button>
                <button class="btn btn-mini btn-success">
                    下架
                </button>
            </div>
          </td>
        </tr>


        <tr>
          <td class="center">
            <label><input type="checkbox" class="input"><span class="lbl"></span></label>
          </td>
          <td>电饭煲</td>
          <td>电器</td>
          <td class="hidden-480"><img src="image/goods.png" alt="" class="imgList"></td>
          <td><span class="label label-sm label-info arrowed arrowed-righ">上架中</span></td>

          <td>
            <div class="inline position-relative" >
              <button class="btn btn-mini btn-info" data-toggle="modal" data-target="#myModal"><i class="icon-edit"></i></button>
              <button class="btn btn-mini btn-danger"><i class="icon-trash"></i></button>
                <button class="btn btn-mini btn-success">
                    下架
                </button>
            </div>
          </td>
        </tr>

              </tbody>
    </table>
    <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">新增</button>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">商品信息</h4>
      </div>
      <div class="modal-body" >
          <form class="form-horizontal">

            <div class="control-group">
              <p class="red">商品标题准确、简洁、完整</p>
              <label class="control-label" for="form-field-1">商品标题</label>
              <div class="controls">
                <select id="form-field-select-1">

                  <option value=""></option>
                  <option value="AL">Alabama</option>
                  <option value="AK">Alaska</option>
                </select>
              </div>
            </div>
            <div class="control-group">
                <p class="red">请先选择GMC借卖平台商品大类，此分类决定了您的商品在借卖平台中展示的位置</p>
              <label class="control-label" for="form-field-1">商品分类</label>
              <div class="controls">
                <select id="form-field-select-2" multiple="multiple">

                  <option value="AL">Alabama</option>
                   <option value="AK">Alaska</option>
                   <option value="AZ">Arizona</option>
                </select>
                 <select id="form-field-select-2" multiple="multiple">

                  <option value="AL">Alabama</option>
                   <option value="AK">Alaska</option>
                   <option value="AZ">Arizona</option>
                </select>
              </div>
            </div>


            <div class="control-group">
                <p class="red">
                    图片要求：

                    最多可以上传12张图：eBay 12张、Amazon 9张；
                    分辨率1000像素（高度）X 1000像素（宽度）以上；
                    正方形，为无水印白底图或情景图，商品占图片80%；
                    可以是多角度拍摄商品图片，也可以是细节图。
                </p>
              <label class="control-label" for="form-field-1">商品主图</label>

              <div class="controls">
                  <span style="font-size:14px;"><div id="uploader-demo">
                  <!--用来存放item-->
                  <div id="thelist" class="uploader-list"></div>
                  <div>
                   <div id="filePicker">选择图片</div>
                   <button id="ctlBtn" class="btn btn-default">开始上传</button>
                  </div>
                     <small class="blue">商品主图第1张图片，将出现在商
                        品列表页、商品详情页第一张图等</small>
                  </div>
                  </span>







              </div>
            </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal">保存</button>
      </div>
    </div>
  </div>
</div>
  </div></div>

    <script src="js/jquery-1.9.1.js"></script>
    <script src="webuploader/webuploader.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootbox.min.js"></script>
   <script type="text/javascript">
  $(function(){
   /*init webuploader*/
   var $list=$("#thelist");   //这几个初始化全局的百度文档上没说明，好蛋疼。
   var $btn =$("#ctlBtn");   //开始上传
   var thumbnailWidth = 100;   //缩略图高度和宽度 （单位是像素），当宽高度是0~1的时候，是按照百分比计算，具体可以看api文档
   var thumbnailHeight = 100;

   var uploader = WebUploader.create({
       // 选完文件后，是否自动上传。
       auto: false,

       // swf文件路径
       swf: '/Uploader.swf',

       // 文件接收服务端。
       server: 'http://webuploader.duapp.com/server/fileupload.php',

       // 选择文件的按钮。可选。
       // 内部根据当前运行是创建，可能是input元素，也可能是flash.
       pick: '#filePicker',

       // 只允许选择图片文件。
       accept: {
           title: 'Images',
           extensions: 'gif,jpg,jpeg,bmp,png',
           mimeTypes: 'image/*'
       },
       method:'POST',
   });
   // 当有文件添加进来的时候
   uploader.on( 'fileQueued', function( file ) {  // webuploader事件.当选择文件后，文件被加载到文件队列中，触发该事件。等效于 uploader.onFileueued = function(file){...} ，类似js的事件定义。
       var $li = $(
               '<div id="' + file.id + '" class="file-item thumbnail">' +
                   '<img>' +
                   '<div class="info">' + file.name + '</div>' +
               '</div>'
               ),
           $img = $li.find('img');


       // $list为容器jQuery实例
       $list.append( $li );

       // 创建缩略图
       // 如果为非图片文件，可以不用调用此方法。
       // thumbnailWidth x thumbnailHeight 为 100 x 100
       uploader.makeThumb( file, function( error, src ) {   //webuploader方法
           if ( error ) {
               $img.replaceWith('<span>不能预览</span>');
               return;
           }

           $img.attr( 'src', src );
       }, thumbnailWidth, thumbnailHeight );
   });
   // 文件上传过程中创建进度条实时显示。
   uploader.on( 'uploadProgress', function( file, percentage ) {
       var $li = $( '#'+file.id ),
           $percent = $li.find('.progress span');

       // 避免重复创建
       if ( !$percent.length ) {
           $percent = $('<p class="progress"><span></span></p>')
                   .appendTo( $li )
                   .find('span');
       }

       $percent.css( 'width', percentage * 100 + '%' );
   });

   // 文件上传成功，给item添加成功class, 用样式标记上传成功。
   uploader.on( 'uploadSuccess', function( file ) {
       $( '#'+file.id ).addClass('upload-state-done');
   });

   // 文件上传失败，显示上传出错。
   uploader.on( 'uploadError', function( file ) {
       var $li = $( '#'+file.id ),
           $error = $li.find('div.error');

       // 避免重复创建
       if ( !$error.length ) {
           $error = $('<div class="error"></div>').appendTo( $li );
       }

       $error.text('上传失败');
   });

   // 完成上传完了，成功或者失败，先删除进度条。
   uploader.on( 'uploadComplete', function( file ) {
       $( '#'+file.id ).find('.progress').remove();
   });
      $btn.on( 'click', function() {
        console.log("上传...");
        uploader.upload();
        console.log("上传成功");
      });

        $('.ace-checkbox-2').change(function(){
          if($('.ace-checkbox-2').prop('checked')){
            $('.input').prop('checked',true);
          }else{
            $('.input').prop('checked',false);
          }
        })

        $('.btn-danger').click(function(){
            bootbox.alert("删除成功！");
        })
  });
 </script>
    </body>
</html>
